<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>Coke</h1>
<button>按钮</button>
<script>
var h1 = document.querySelector('h1');
var btn = document.querySelector('button');

// 死循环指定的时间
function delay(duration) {
    var start = Date.now();
    while (Date.now() - start < duration) {
    }
}

btn.onclick = function () {
    h1.textContent = 'Coke很帅！'
    delay(3000)
};
</script>
</body>
</html>
